<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2021-11-22 10:10:15
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-05-06 17:29:28
-->
<template>
  <div class="app-container">
    <div class="chioose-header">
      <div class="chioose-header-left">
        <div
          class="tab-title"
          v-for="(item, index) in tabList"
          :key="index"
          :class="item.id === active1 ? 'active1' : ''"
          @click="changeTab(item)"
        >
          {{ item.label }}
        </div>
      </div>
      <div class="search" style="margin-left: 10%">
        <el-input
          v-model="input"
          placeholder="搜索订单内容/订单金额"
          size="normal"
          clearable
          style="width: 220px; height: 40px"
        ></el-input>
        <el-button type="primary" size="default" @click="search">
          搜索
        </el-button>
      </div>
    </div>

    <div v-if="status == 0">
      <table-header></table-header>
      <all-order class="table-size" :orderData="orderData"></all-order>
      <!-- 分页器 -->
      <el-pagination
        prev-text="上一页"
        next-text="下一页"
        background
        :page-size="pageSize"
        :page-sizes="[10, 20, 30, 40, 50, 100]"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        layout=" ->,total, sizes,prev, pager, next, jumper "
        :total="total"
      >
      </el-pagination>
    </div>
    <div v-else-if="status == 1">
      <inv-record></inv-record>
    </div>
    <div v-else-if="status == 2">
      <address-man></address-man>
    </div>
    <div v-else-if="status == 3">
      <increment></increment>
    </div>
  </div>
</template>

<script>
import { invoiceList } from "@/api/enterprise/invoiceAst";
import AddressMan from "./conponments/invoiceAst/addressMan.vue";
import AllOrder from "./conponments/invoiceAst/allOrder.vue";
import Increment from "./conponments/invoiceAst/increment.vue";
import InvRecord from "./conponments/invoiceAst/invRecord.vue";
import tableHeader from "./conponments/invoiceAst/tableHeader.vue";
export default {
  components: { tableHeader, AllOrder, AddressMan, InvRecord, Increment },
  data() {
    return {
      pageNum: 1,
      pageSize: 10,
      active1: 0,
      total: 0,
      input: "",
      status: 0,
      orderData: [],
      tabList: [
        {
          id: 0,
          label: "申请发票",
        },
        {
          id: 1,
          label: "开票记录",
        },
        {
          id: 2,
          label: "发票地址管理",
        },
        {
          id: 3,
          label: "增值发票管理 ",
        },
      ],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //   搜索
    search() {
      this.getList();
    },
    //   请求列表
    getList() {
      invoiceList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        identification: this.input,
      }).then((res) => {
        this.orderData = res.rows;
        this.total = res.total;
      });
    },
    // 列表切换
    changeTab(item) {
      this.active1 = item.id;
      if (item.id == 0) {
        this.status = 0;
        this.getList();
      } else if (item.id == 1) {
        this.status = 1;
      } else if (item.id == 2) {
        this.status = 2;
      } else {
        this.status = 3;
      }
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.pageNum = 1;
      this.getList();
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getList();
    },
  },
};
</script>

<style lang="less" scoped>
.chioose-header {
  width: 100%;
  height: 64px;
  line-height: 64px;
  border-bottom: 1px solid #ececec;
  display: flex;
}
.chioose-header-left {
  display: flex;
}
.tab-title {
  display: flex;
  margin-right: 44px;
  cursor: pointer;
  font-size: 16px;
}
.active1 {
  font-weight: 700;
  border-bottom: 2px solid #1267fa;
  color: #1267fa;
}
.table-size {
  height: 72vh;
  border-bottom: 1px solid #ececec;
  overflow-y: auto;
}
.el-pagination {
  margin-top: 24px;
  /deep/ .el-pagination__total {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    margin-right: 25px;
  }
  /deep/ .btn-prev {
    width: 80px;
    height: 40px;
    text-align: center;
  }
  /deep/ .btn-next {
    width: 80px;
    height: 40px;
    text-align: center;
  }
  /deep/ .number {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .el-input__inner {
    // width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .more {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .el-pagination__jump {
    .el-input__inner {
      width: 40px;
      height: 40px;
    }
  }
}
</style>